#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 
# Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
# 

"""
File: run7.py
Author: zhangyang(zhangyang40@baidu.com)
Date: 2018/1/5 0005 12:45
"""
"""
输入一个整数，输出该数二进制表示中1的个数。其中负数用补码表示。
"""


class Solution:
    def NumberOf1(self, n):
        count = 0
        while n != 0:
            count += 1
            n = n & (n - 1)
        return count
